package com.ymatou.iapi.godmch.testcase;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.springframework.context.support.StaticApplicationContext;

import com.sun.org.apache.bcel.internal.generic.NEW;
import com.ymatou.iapi.godmch.parameter.SetMarkupConfigBean;
import com.ymatou.iapi.godmch.parameter.applySupplierBean;
import com.ymatou.iapi.godmch.parameter.createIndepMchBean;
import com.ymatou.iapi.godmch.parameter.setConditionMarkupConfigBean;
import com.ymatou.iapi.godmch.parameter.supplierListBean;
import com.ymatou.iapi.godmch.service.applyAgentCall;
import com.ymatou.iapi.godmch.service.applySupplierCall;
import com.ymatou.iapi.godmch.service.createIndepMchCall;
import com.ymatou.iapi.godmch.service.supplierListCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.MarkupConfig;
import com.ymttest.database.model.country_info;
import com.ymttest.database.model.mch_info;
import com.ymttest.database.model.mch_relation;
import com.ymttest.database.sqlwapper.godmch.MarkupconfigWapper;
import com.ymttest.database.sqlwapper.godmch.country_infoWapper;
import com.ymttest.database.sqlwapper.godmch.invite_codeWapper;
import com.ymttest.database.sqlwapper.godmch.mch_infoWapper;
import com.ymttest.database.sqlwapper.godmch.mch_relationWapper;
/**
*供货商列表
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_supplierList{
	private static supplierListBean bean;
	private static supplierListCall call;
	
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	
	private static country_infoWapper countryinfoWapper=new country_infoWapper();
	private static mch_relationWapper mchrelationWapper=new mch_relationWapper();
	private static mch_infoWapper mchInfoWapper=new mch_infoWapper();
	
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("供货商列表");
	}

	@Before
	public void caseUp() {
		bean=new supplierListBean();
		call=new supplierListCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	private void check_markupConfig(JSONObject act_obj,Integer mchId,Integer parentMchId) throws JSONException, InterruptedException{
		//返回自动加价markupConfig
		  MarkupConfig markupConfig=new MarkupConfig();
		  List<MarkupConfig> markupConfigs = new MarkupconfigWapper().selectbyPrimaryKey(mchId,parentMchId);
		  if(markupConfigs.size()>0){
			  JSONObject markup_obj=act_obj.getJSONObject("markupConfig");
			  markupConfig=markupConfigs.get(0);
			  Logger.verifyEquals(markupConfig.getMarkupType(), markup_obj.get("markupType"), "验证返回的MarkupType与数据库MarkupConfig中的MarkupType一致");
			  Logger.verifyEquals(markupConfig.getPercentage().stripTrailingZeros().toPlainString(), 
					  new BigDecimal(markup_obj.getString("percentage")).stripTrailingZeros().toPlainString(), "验证返回的MarkupType与数据库MarkupConfig中的percentage一致");
			  Logger.verifyEquals(markupConfig.getDecimalType(), markup_obj.get("decimalType"), "验证返回的MarkupType与数据库MarkupConfig中的decimalType一致");
			  Logger.verifyEquals(markupConfig.getOnSaleType(), markup_obj.get("onSaleType"), "验证返回的MarkupType与数据库MarkupConfig中的onSaleType一致");
			  Logger.verifyEquals(markupConfig.getRefreshProduct(), markup_obj.get("refreshProduct"), "验证返回的MarkupType与数据库MarkupConfig中的refreshProduct一致");
		  }
	}
	/**
	 * 校验
	 * @param state 审核状态
	 * @throws InterruptedException
	 * @throws JSONException
	 */
	private  void check_verify(applySupplierBean applySupplierBean) throws InterruptedException, JSONException {
		Integer m_state=0;
		if(bean.getStatus()==1) m_state=0;
		if(bean.getStatus()==2) m_state=-2;
		if(bean.getStatus()==3) m_state=-3;
		//验证
		Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
		Logger.verifyEquals(true, call.getMessage().contains("请求成功"), "验证Message");
		//关系mch_relation mchId=bean.getMchId()
		Map<String,Object> map=new HashMap<>();
		map.put("mchId", bean.getMchId());
		map.put("state", m_state);//state 0:正常 -1：删除 -2：待审核 -3：审核拒绝
		List<mch_relation> mchrelations=mchrelationWapper.selectby(map);
		Logger.verifyEquals(call.getTotal(), mchrelations.size(), "验证返回的供货商总数");
		
		for(int i=0;i<call.getList().length();i++)
		{
		  mch_relation m=mchrelations.get(i);
		  JSONObject act_obj= call.getList().getJSONObject(i);
		  
		  if(m.getParentMchId().equals(act_obj.getInt("supplierId"))){
			  
			    Logger.comment("####supplierId:"+act_obj.getInt("supplierId"));
				//查询供货商
				Map<String,Object> supplier_map=new HashMap();
				supplier_map.put("mchId", m.getParentMchId());
				mch_info mchInfo=mchInfoWapper.selectby(supplier_map).get(0);
				Logger.verifyEquals(mchInfo.getAvatar(), act_obj.getString("avatar"), "验证返回第"+(i+1)+"条avatar数据与数据库中的avatar一致");
				Logger.verifyEquals(mchInfo.getMchTitle(), act_obj.getString("title"), "验证返回第"+(i+1)+"条title数据与数据库中的tiMchTitletle一致");
				//若是审核通过 取值是createTime ,其他都是 updateTime
				if(m.getState()==0)//0：正常 -1：删除 -2：待审核 -3：审核拒绝
			    	Logger.verifyEquals(sdf.format(mchInfo.getCreateTime()), act_obj.get("applyTime"), "验证返回第"+(i+1)+"条applyTime数据与数据库中的CreateTime一致");
				else 
					Logger.verifyEquals(sdf.format(mchInfo.getUpdateTime()), act_obj.get("applyTime"), "验证返回第"+(i+1)+"条applyTime数据与数据库中的UpdateTime一致");
				
				//查询国家表
				country_info country_info=countryinfoWapper.selectByPrimaryKey(mchInfo.getCountry());
				Logger.verifyEquals(country_info.getAreaCode(), act_obj.getString("areaCode"), "验证返回第"+(i+1)+"条avatar数据与数据库中的avatar一致");
				
				if(bean.getPageSize()==1){
				  act_obj= call.getList().getJSONObject(0);
				  Logger.verifyEquals(applySupplierBean.getMobile(), act_obj.getString("mobile"), "验证返回第1条mobile数据与数据库中的mobile一致");
				}
			}
		 //返回自动加价markupConfig 新增 20200410
		  check_markupConfig(act_obj,m.getMchId(), m.getParentMchId());
		  
		  
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_001() {
		Logger.start(true,"正例-供货商列表-无代理独立商户-1：已通过-成功");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商
            applySupplierBean applySupplierBean=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean);
            //通过
            GodmchManageCallService.approveSupplier(createIndepMchCall.getmchId(), applySupplierCall.getSupplierId());
            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(1);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(1);
            bean.setPageSize(5);
			call.setData(bean);
			call.callService();			
			
			check_verify(applySupplierBean);
			
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_002() {
		Logger.start(true,"正例-供货商列表-无代理独立商户-2：待审核-成功");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商
            applySupplierBean applySupplierBean=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean);
            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(2);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(1);
            bean.setPageSize(5);
			call.setData(bean);
			call.callService();			
			
			check_verify(applySupplierBean);
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_003() {
		Logger.start(true,"正例-供货商列表-无代理独立商户-3：已拒绝-成功");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商
            applySupplierBean applySupplierBean=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean);
            //拒绝
            GodmchManageCallService.rejectSupplier(createIndepMchCall.getmchId(), applySupplierCall.getSupplierId());
            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(3);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(1);
            bean.setPageSize(5);
			call.setData(bean);
			call.callService();			
			
			check_verify(applySupplierBean);

			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_004() {
		Logger.start(true,"正例-供货商列表-有代理独立商户-已通过-成功");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请独立商户的代理
            GodmchManageCallService.applyAndapproveAgent(createIndepMchCall.getmchId());
            //申请供货商
            applySupplierBean applySupplierBean=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean);
            //通过
            GodmchManageCallService.approveSupplier(createIndepMchCall.getmchId(), applySupplierCall.getSupplierId());
            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(1);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(1);
            bean.setPageSize(5);
			call.setData(bean);
			call.callService();			
			
			check_verify(applySupplierBean);
			
	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_005() {
		Logger.start(true,"正例-供货商列表-有代理独立商户-待审核-成功");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请独立商户的代理
            GodmchManageCallService.applyAndapproveAgent(createIndepMchCall.getmchId());
            //申请供货商
            applySupplierBean applySupplierBean=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean);
           
            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(2);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(1);
            bean.setPageSize(5);
			call.setData(bean);
			call.callService();			
			
			check_verify(applySupplierBean);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_006() {
		Logger.start(true,"正例-供货商列表-有代理独立商户-已拒绝-成功");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请独立商户的代理
            GodmchManageCallService.applyAndapproveAgent(createIndepMchCall.getmchId());
            //申请供货商
            applySupplierBean applySupplierBean=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean);
           //拒绝
            GodmchManageCallService.rejectSupplier(createIndepMchCall.getmchId(), applySupplierCall.getSupplierId());
            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(3);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(1);
            bean.setPageSize(5);
			call.setData(bean);
			call.callService();			
			
			check_verify(applySupplierBean);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_006_1() {
		Logger.start(true,"正例-供货商列表-包含多个状态的供货商-查询条件传入待审核-成功");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商1
            applySupplierBean applySupplierBean1=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean1);
            
            //申请供货商2
            applySupplierBean applySupplierBean2=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall2=GodmchManageCallService.applySupplierCall(applySupplierBean2);
            //拒绝
            GodmchManageCallService.rejectSupplier(createIndepMchCall.getmchId(), applySupplierCall2.getSupplierId());
            
            //申请供货商3
            applySupplierBean applySupplierBean3=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall3= GodmchManageCallService.applySupplierCall(applySupplierBean3);
            //通过
            GodmchManageCallService.approveSupplier(createIndepMchCall.getmchId(), applySupplierCall3.getSupplierId());
            //删除
            GodmchManageCallService.deleteSupplier(createIndepMchCall.getmchId(), applySupplierCall3.getSupplierId());
            
            //申请供货商4
            applySupplierBean applySupplierBean4=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall4=GodmchManageCallService.applySupplierCall(applySupplierBean4);
            //通过
            GodmchManageCallService.approveSupplier(createIndepMchCall.getmchId(), applySupplierCall4.getSupplierId());
            
            //申请供货商5
            applySupplierBean applySupplierBean5=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall5= GodmchManageCallService.applySupplierCall(applySupplierBean5);
            //拒绝
            GodmchManageCallService.rejectSupplier(createIndepMchCall.getmchId(), applySupplierCall5.getSupplierId());
            //拒绝重新申请
            GodmchManageCallService.ReApplySupplier(createIndepMchCall.getmchId(), applySupplierCall5.getSupplierId());
            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(2);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(1);
            bean.setPageSize(3);
			call.setData(bean);
			call.callService();			
			
			check_verify(applySupplierBean1);	
			
			Logger.verifyEquals(applySupplierBean1.getMobile(), call.getList().getJSONObject(1).getString("mobile"), "验证返回第2条mobile数据与数据库中的mobile一致");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_010() {
		Logger.start(true,"正例-供货商列表-显示中间页-第二页pageIndex=2,pageSize=1-成功");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商1
            applySupplierBean applySupplierBean1=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean1);
            //申请供货商2
            applySupplierBean applySupplierBean2=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            GodmchManageCallService.applySupplierCall(applySupplierBean2);
            //申请供货商3
            applySupplierBean applySupplierBean3=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            GodmchManageCallService.applySupplierCall(applySupplierBean3);
   
            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(2);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(2);
            bean.setPageSize(1);
			call.setData(bean);
			call.callService();			
			
			check_verify(applySupplierBean2);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_010_1() {
		Logger.start(true,"正例-供货商列表-第一页显示多条-pageIndex=1,pageSize=2-返回成功");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商1
            applySupplierBean applySupplierBean1=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean1);
            //申请供货商2
            applySupplierBean applySupplierBean2=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            GodmchManageCallService.applySupplierCall(applySupplierBean2);
            //申请供货商3
            applySupplierBean applySupplierBean3=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            GodmchManageCallService.applySupplierCall(applySupplierBean3);
   
            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(2);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(1);
            bean.setPageSize(2);
			call.setData(bean);
			call.callService();			
			
			check_verify(applySupplierBean1);	

			Logger.verifyEquals(applySupplierBean3.getMobile(), call.getList().getJSONObject(0).getString("mobile"), "验证返回第1条mobile数据与数据库中的mobile一致");
			Logger.verifyEquals(applySupplierBean2.getMobile(), call.getList().getJSONObject(1).getString("mobile"), "验证返回第2条mobile数据与数据库中的mobile一致");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_010_2() {
		Logger.start(true,"正例-供货商列表-第二页显示多条-pageIndex=2,pageSize=2-返回成功");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商1
            applySupplierBean applySupplierBean1=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean1);
            //申请供货商2
            applySupplierBean applySupplierBean2=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            GodmchManageCallService.applySupplierCall(applySupplierBean2);
            //申请供货商3
            applySupplierBean applySupplierBean3=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            GodmchManageCallService.applySupplierCall(applySupplierBean3);
            //申请供货商4
            applySupplierBean applySupplierBean4=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            GodmchManageCallService.applySupplierCall(applySupplierBean4);
            //申请供货商5
            applySupplierBean applySupplierBean5=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            GodmchManageCallService.applySupplierCall(applySupplierBean5);
            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(2);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(2);
            bean.setPageSize(2);
			call.setData(bean);
			call.callService();			
			
			check_verify(applySupplierBean1);	

			Logger.verifyEquals(applySupplierBean3.getMobile(), call.getList().getJSONObject(0).getString("mobile"), "验证返回第1条mobile数据与数据库中的mobile一致");
			Logger.verifyEquals(applySupplierBean2.getMobile(), call.getList().getJSONObject(1).getString("mobile"), "验证返回第2条mobile数据与数据库中的mobile一致");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_010_3() {
		Logger.start(true,"正例-供货商列表-最后一页显示多条-pageIndex=2,pageSize=3-返回成功");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商1
            applySupplierBean applySupplierBean1=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean1);
            //申请供货商2
            applySupplierBean applySupplierBean2=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            GodmchManageCallService.applySupplierCall(applySupplierBean2);
            //申请供货商3
            applySupplierBean applySupplierBean3=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            GodmchManageCallService.applySupplierCall(applySupplierBean3);
            //申请供货商4
            applySupplierBean applySupplierBean4=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            GodmchManageCallService.applySupplierCall(applySupplierBean4);
            //申请供货商5
            applySupplierBean applySupplierBean5=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            GodmchManageCallService.applySupplierCall(applySupplierBean5);
            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(2);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(2);
            bean.setPageSize(3);
			call.setData(bean);
			call.callService();			
			
			check_verify(applySupplierBean1);	

			Logger.verifyEquals(applySupplierBean2.getMobile(), call.getList().getJSONObject(0).getString("mobile"), "验证返回第1条mobile数据与数据库中的mobile一致");
			Logger.verifyEquals(applySupplierBean1.getMobile(), call.getList().getJSONObject(1).getString("mobile"), "验证返回第2条mobile数据与数据库中的mobile一致");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_011() {
		Logger.start(true,"正例-供货商列表-显示最后一页pageIndex=max,pageSize=1-成功");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商1
            applySupplierBean applySupplierBean1=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean1);
            //申请供货商2
            applySupplierBean applySupplierBean2=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            GodmchManageCallService.applySupplierCall(applySupplierBean2);
            //申请供货商3
            applySupplierBean applySupplierBean3=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            GodmchManageCallService.applySupplierCall(applySupplierBean3);
   
            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(2);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(3);
            bean.setPageSize(1);
			call.setData(bean);
			call.callService();			
			
			check_verify(applySupplierBean1);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_012() {
		Logger.start(true,"正例-供货商列表-大于当前最大页pageIndex=max+1,pageSize=1-返回空");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商1
            applySupplierBean applySupplierBean1=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean1);
            //申请供货商2
            applySupplierBean applySupplierBean2=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            GodmchManageCallService.applySupplierCall(applySupplierBean2);
   
            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(2);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(3);
            bean.setPageSize(1);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals(true, call.getMessage().contains("请求成功"), "验证Message");
		
			Logger.verifyEquals(2,call.getTotal(), "验证返回的供货商总数");
			Logger.verifyEquals(0,call.getList().length(), "验证返回的供货商的集合");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_013() {
		Logger.start(true,"正例-供货商列表-当前页大于最大条数-pageIndex=999999999-返回空");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商1
            applySupplierBean applySupplierBean1=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean1);
//            //申请供货商2
//            applySupplierBean applySupplierBean2=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
//            GodmchManageCallService.applySupplierCall(applySupplierBean2);
//            //申请供货商3
//            applySupplierBean applySupplierBean3=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
//            GodmchManageCallService.applySupplierCall(applySupplierBean3);
   
            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(2);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(1);
            bean.setPageSize(10);//大于最大条数
			call.setData(bean);
			call.callService();			
			
			check_verify(applySupplierBean1);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_014() {
		Logger.start(true,"正例-供货商列表-每页条数大于最大条数-pageIndex=1,pageSize=999999999-成功");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商1
            applySupplierBean applySupplierBean1=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean1);
//            //申请供货商2
//            applySupplierBean applySupplierBean2=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
//            GodmchManageCallService.applySupplierCall(applySupplierBean2);
//            //申请供货商3
//            applySupplierBean applySupplierBean3=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
//            GodmchManageCallService.applySupplierCall(applySupplierBean3);
   
            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(2);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(1);
            bean.setPageSize(999999999);//大于最大条数
			call.setData(bean);
			call.callService();			
			
			check_verify(applySupplierBean1);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_015() {
		Logger.start(true,"反例-供货商列表-状态不存在status=9999-失败");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商
            applySupplierBean applySupplierBean=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean);

            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(9999);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(1);
            bean.setPageSize(5);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("4001", call.getStatusCode1(), "验证status");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_016() {
		Logger.start(true,"反例-供货商列表-pageIndex=0-返回空");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商
            applySupplierBean applySupplierBean=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean);
          
            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(2);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(0);
            bean.setPageSize(5);
			call.setData(bean);
			call.callService();				
			Logger.verifyEquals("4001", call.getStatusCode1(), "验证status");	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_017() {
		Logger.start(true,"反例-供货商列表-pageSize=0-返回空");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商
            applySupplierBean applySupplierBean=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean);
            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(2);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(1);
            bean.setPageSize(0);
			call.setData(bean);
			call.callService();				
			Logger.verifyEquals("4001", call.getStatusCode1(), "验证status");			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_018() {
		Logger.start(true,"反例-供货商列表-mchId不存在-返回空");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商
            applySupplierBean applySupplierBean=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean);
          
            
            bean.setMchId(createIndepMchCall.getmchId()+99);
            bean.setStatus(2);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(1);
            bean.setPageSize(5);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals(true, call.getMessage().contains("请求成功"), "验证Message");
			Logger.verifyEquals(0, call.getTotal(), "验证Total");
			Logger.verifyEquals(0, call.getList().length(), "验证返回供货商集合为空");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_020() {
		Logger.start(true,"反例-供货商列表-mchId为空-失败");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商
            applySupplierBean applySupplierBean=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean);
            
            //bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(2);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(1);
            bean.setPageSize(0);
			call.setData(bean);
			call.callService();				
			Logger.verifyEquals("4001", call.getStatusCode1(), "验证status");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_021() {
		Logger.start(true,"反例-供货商列表-status为空-失败");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商
            applySupplierBean applySupplierBean=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean);
            
            bean.setMchId(createIndepMchCall.getmchId());
           // bean.setStatus(2);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(1);
            bean.setPageSize(0);
			call.setData(bean);
			call.callService();				
			Logger.verifyEquals("4001", call.getStatusCode1(), "验证status");			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_022() {
		Logger.start(true,"反例-供货商列表-appKey为空-失败");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商
            applySupplierBean applySupplierBean=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean);
            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(2);//状态 1：已通过 2：待审核 3：已拒绝
          //  bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(1);
            bean.setPageSize(0);
			call.setData(bean);
			call.callService();				
			Logger.verifyEquals("4001", call.getStatusCode1(), "验证status");			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	//新增 20200407
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_023() {
		Logger.start(true,"正例-供货商列表-无代理-配置过的自动加价-成功");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请供货商
            applySupplierBean applySupplierBean=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean);
            //通过
            GodmchManageCallService.approveSupplier(createIndepMchCall.getmchId(), applySupplierCall.getSupplierId());
            
        	List<Integer> supplierIds=new ArrayList();
        	supplierIds.add(applySupplierCall.getSupplierId());
			SetMarkupConfigBean SetMarkupConfigBean=GodmchManageCallService.initSetMarkupConfigV2
					(applySupplierBean.getMchId(),supplierIds);
			GodmchManageCallService.SetMarketupBeanCall(SetMarkupConfigBean);
			
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(1);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(1);
            bean.setPageSize(5);
			call.setData(bean);
			call.callService();			
			
			check_verify(applySupplierBean);
			
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_supplierList_024() {
		Logger.start(true,"正例-供货商列表-设置自动加价-成功-20200708");
		try {
			//创建独立商户
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            //申请独立商户的代理
          //  applyAgentCall applyAgentCall= GodmchManageCallService.applyAndapproveAgent(createIndepMchCall.getmchId());
            //申请供货商
            applySupplierBean applySupplierBean=GodmchManageCallService.initApplySupplier(createIndepMchCall.getmchId());
            applySupplierCall applySupplierCall=GodmchManageCallService.applySupplierCall(applySupplierBean);
            //通过
            GodmchManageCallService.approveSupplier(createIndepMchCall.getmchId(), applySupplierCall.getSupplierId());
			 //新增
	         //setConditionMarkupConfigBean setBean=GodmchManageCallService.initSetConditionMarkupConfig(applyAgentCall.getAgentId(),applySupplierCall.getSupplierId());
            setConditionMarkupConfigBean setBean=GodmchManageCallService.initSetConditionMarkupConfig(createIndepMchCall.getmchId(),applySupplierCall.getSupplierId());
	         GodmchManageCallService.setConditionMarkupConfigCall(setBean);
            
            bean.setMchId(createIndepMchCall.getmchId());
            bean.setStatus(1);//状态 1：已通过 2：待审核 3：已拒绝
            bean.setAppKey("appsqSeller_"+createIndepMchCall.getmchId());
            bean.setPageIndex(1);
            bean.setPageSize(5);
			call.setData(bean);
			call.callService();			
			
			check_verify(applySupplierBean);

			JSONObject act_obj= call.getList().getJSONObject(0);
			Logger.verifyEquals(true, act_obj.get("setConditionMarkup"), "验证setConditionMarkup=true");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}